package com.mvp.shq.washer.ui.qrcodeShare;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.zxing.WriterException;
import com.google.zxing.encoding.EncodingHandler;
import com.mvp.shq.washer.R;
import com.mvp.shq.washer.base.BaseActivity;
import com.mvp.shq.washer.entity.User;
import com.mvp.shq.washer.utils.SpUtil;
import com.mvp.shq.washer.utils.T;
import com.orhanobut.logger.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class QrcodeShareActivity extends BaseActivity<Presenter, Model> implements QrcodeShareConstract.View {


    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.img_qrcode)
    ImageView imgQrcode;

    @Override
    public int getLayoutId() {
        return R.layout.activity_qrcode_share;
    }

    @Override
    public void initView() {
        User user = SpUtil.getUser();
        String url = "http://gzh.uzhixi.com/uzhixiDownload/register.html?userId="+user.getId()+"&mobile="+user.getMobile() + "&shareType=3";
        //T.show(user.getMobile());
        Logger.d(url);
        try {
            Bitmap mBitmap = EncodingHandler.createQRCode(url, 280);
            imgQrcode.setImageBitmap(mBitmap);
        } catch (WriterException e) {
            e.printStackTrace();
        }
    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }
}
